<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* ES6 class 语法 */
      class Animal {
        constructor(name) {
          this.name = name
        }
        getName() {
          return this.name
        }
      }

      // 继承
      class Dog extends Animal {
        constructor(name) {
          super(name)
        }
        speak() {
          return '汪汪汪'
        }
      }

      var dog = new Dog('小黄')
      console.log(dog.getName() + 'say:' + dog.speak()) // 小黄say:汪汪汪
    </script>
  </body>
</html>
